﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace TimeStart
{
    public partial class Import : Form
    {
        TextReader input;
        public Import()
        {
            InitializeComponent();
        }

        private void Importa_Load(object sender, EventArgs e)
        {
            this.Text = Home.tmex[30];
            webBrowser.Navigate("http://www.pietrosoft.altervista.org/timestart/ads.html");
            cimport.Text = Home.tmex[29];
            if (File.Exists("RECORDS\\IMPORTED-LOG.txt") == true)
            {
                input = new StreamReader("RECORDS\\IMPORTED-LOG.txt");
                tmain.Text = input.ReadToEnd();
                input.Close();
                cimport.Enabled = false;
            }

        }

        private void cimport_Click(object sender, EventArgs e)
        {
            string temp;
            System.Diagnostics.EventLog LookFor = new System.Diagnostics.EventLog();
            LookFor.Log = "System";
            TextWriter output = new StreamWriter("RECORDS\\IMPORTED-LOG.txt",true,Encoding.UTF8);
            foreach (System.Diagnostics.EventLogEntry entry in LookFor.Entries)
            {
                if (entry.EventID == 6005 || entry.EventID == 6006)
                {
                    if (entry.EventID == 6005)
                        temp = entry.TimeGenerated.Day + "/" + entry.TimeGenerated.Month + "/" + entry.TimeGenerated.Year + " - " + Home.tmex[31] + " " + entry.TimeGenerated.Hour + ":" + entry.TimeGenerated.Minute + ":" + entry.TimeGenerated.Second;
                    else
                        temp = entry.TimeGenerated.Day + "/" + entry.TimeGenerated.Month + "/" + entry.TimeGenerated.Year + " - " + Home.tmex[32] + " " + entry.TimeGenerated.Hour + ":" + entry.TimeGenerated.Minute + ":" + entry.TimeGenerated.Second;
                    output.WriteLine(temp);

                }
            }
            output.Close();
            input = new StreamReader("RECORDS\\IMPORTED-LOG.txt",Encoding.UTF8);
            tmain.Text = input.ReadToEnd();
            input.Close();
            cimport.Enabled = false;
        }
        }
    }

